import {
    ContainerOutlined,
    DesktopOutlined,
    PieChartOutlined,
    MenuUnfoldOutlined
} from '@ant-design/icons';
import { Menu } from 'antd';
import React, { useState, useEffect } from 'react';
import { request, history } from 'umi';

const icons: any = {
    "/lotteryWhiteList": <ContainerOutlined />,
    "/createActivity": <DesktopOutlined />,
    "/activityComment": <PieChartOutlined />,
    "/move": <MenuUnfoldOutlined />,
}
export default function Menus(props: any) {
    const onClick = (e: any) => {
        history.push(e.key)
    }
    let [menuslist, setMenulist] = useState<any>([])
    useEffect(() => {
        request("/campus/campusweb/menu/listOthersMenuForUser", {
            method: 'post',
            data: {
                parentId: 1001
            }
        }).then(res => {
            res.data.push({
                menuId: "123",
                menuName: "穿梭器",
                menuUrl: "/move",
                parentId: "1001",
            })
            let data = res.data.map((ele: any) => {
                return {
                    label: ele.menuName,
                    key: ele.menuUrl,
                    icon: icons[ele.menuUrl]
                }
            })
            setMenulist(data)
        })
    }, [])
    return (
        < div >
            {/* 菜单 */}
            < div style={{ width: 256, height: "100%" }}>
                <Menu style={{ height: "100%" }}
                    defaultSelectedKeys={['/lotteryWhiteList']}
                    defaultOpenKeys={['/lotteryWhiteList']}
                    title="秦学后台管理系统"
                    mode="inline"
                    theme="dark"
                    items={menuslist}
                    onClick={onClick}
                />
            </ div>
        </div >
    )
}
